<?php
/**
 * 描述
 * Created by Paco
 * Date: 2018/10/24 Time: 16:06
 */

namespace App\Http\Controllers\Mobile;


use App\Http\Controllers\Controller;
use App\Http\Request\Mobile\User\LoginStore;
use App\Http\Request\Shop\ShopStore;
use App\Repositories\Shop\ShopRepository;
use App\Repositories\User\LoginRepository;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    private $login;

    public function __construct(LoginRepository $login)
    {
        $this->login = $login;
    }

    /**
     * 登录
     * @author: Pako
     * @Email: admin@jqcool.net
     * @Date: 18-10-24 下午9:13
     * @param LoginStore $login
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse|mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function login(LoginStore $login, Request $request)
    {
        $params = $login->validated($request);
        return $this->login->login($params['username'], $params['pid'] ?? 0);
    }


    public function info()
    {
        return $this->login->userInfo();
    }

    public function loginOut(Request $request)
    {

    }

    /**
     *
     * store
     * author Paco
     * createTime 2019/1/29 16:23
     * @param ShopStore $shop
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(ShopStore $shop, Request $request)
    {
        $params = $shop->validated($request);
        return (new ShopRepository($request))->store($params);
    }

}